<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <!--进度条的css-->
    <link rel="stylesheet" href="lib/nprogress/nprogress.css">
    
    <!--bootstrap-->
    <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css">
    <!--表单验证插件的css-->
    <link rel="stylesheet" href="lib/bootstrap-validator/css/bootstrapValidator.min.css">
    <!--自已写的css-->
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/product.css">

    <script src="lib/jquery/jquery.min.js"></script>
    <!--模板引擎-->
    <script src="lib/artTemplate/template-web.js"></script>
    <!--bootstrap-->
    <script src="lib/bootstrap/js/bootstrap.js"></script>
    <!--分页器-->
    <script src="lib/bootstrap-paginator/bootstrap-paginator.min.js"></script>
    <!--表单验证插件-->
    <script src="lib/bootstrap-validator/js/bootstrapValidator.min.js"></script>
    <!--图表插件-->
    <script src="lib/echarts/echarts.min.js"></script>
    <!--上传文件的插件-->
    <script src="lib/jquery-fileupload/jquery.ui.widget.js"></script>
    <script src="lib/jquery-fileupload/jquery.iframe-transport.js"></script>
    <script src="lib/jquery-fileupload/jquery.fileupload.js"></script>
    <!--进度条插件-->
    <script src="lib/nprogress/nprogress.js"></script>
    <!--自已写的js-->
    <script src="js/common.js"></script>
    <script src="./js/product.js"></script>
</head>
<body>
    <div class="main">
        <div class="left">
            <!-- 标题 -->
            <h3 class="title">ITCAST</h3>

            <!-- 头像 -->
            <div class="icon">
                <img src="./images/default.png" alt="">
                <p>超级管理员</p>
            </div>  
            
            <!-- 菜单 -->
            <ul class="menu">
                <li>
                    <a href="user.html"><span class="glyphicon glyphicon-user"></span>用户管理</a>
                </li>
                <li>
                    <a href="javascript:void();" class="togglesubmenu"><span class="glyphicon glyphicon-list"></span>分类管理</a>

                    <div class="submenu">
                        <a href="./category.html">一级分类</a>
                        <a href="./subcategory.html">二级分类</a>
                    </div>
                </li>
                <li>
                    <a href="./product.html" class="active"><span class="glyphicon glyphicon-tags"></span>商品管理</a>
                </li>
            </ul>
        </div>
        <div class="right">
            <div class="topbar">
                <a href="javascript:void();" class="toggle-left pull-left"><span class="glyphicon glyphicon-align-justify"></span></a>
                <a href="javascript:void();" class="log-out pull-right"><span class="glyphicon glyphicon-log-out"></span></a>
            </div>

            <ol class="breadcrumb">
                <li><a href="#">管理系统</a></li>
                <li><a href="#">分类管理</a></li>
                <li><a href="#">二级分类</a></li>
            </ol>

            <div class="content container-fluid">
                <button id="addproduct-btn" class="btn btn-default">添加商品</button>
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>序号</th>
                            <th>商品名称</th>
                            <th>商品描述</th>
                            <th>商品库存</th>
                            <th>商品尺寸</th>
                            <th>商品状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>

                <!-- 实现分页的html -->
                <div class="pull-right">
                    <ul id="pagenator"></ul>
                </div>
            </div>
        </div>
    </div>

    <!-- 一级分类的数据模板 -->
    <script type="text/html" id="product-table">
        {{each rows}} 
        <tr>
            <td>{{(page-1)*size+$index+1}}</td>
            <td>{{$value.proName}}</td>
            <td>{{$value.proDesc}}</td>
            <td>{{$value.num}}</td>
            <td>{{$value.size}}</td>
            <td>
                {{if $value.statu === 1}}已上架{{/if}}
                {{if $value.statu === 0}}已删除{{/if}}
            </td>

            <td>
                {{if $value.statu === 1}}<button type="button" class="btn btn-danger">下架</button>{{/if}}
                {{if $value.statu === 0}}<button type="button" class="btn btn-success">上架</button>{{/if}}
            </td>
        </tr>
        {{/each}}
    </script>
    
    <!-- 添加商品 -->
    <div id="addproduct-modal" class="modal fade bs-example-modal-md" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-md" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">添加商品</h4>
                </div>
                <div class="modal-body">
                        <form>
                            <!-- 下拉框选择一级分类 -->
                                <div class="form-group">
                                    <div class="dropdown">
                                                <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                  <span class="val">二级分类</span>
                                                  <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

                                                </ul>
                                    </div>
                                    
                                    <!-- 需要发送给服务器的，不是分类的名称，而是分类的id，所以，我们需要在选择二级分类之后，同时把id放到下面的这个input框里 -->
                                  <input type="hidden" name="brandId" class="form-control">

                                </div>

                                <!-- 输入二级分类 -->
                                <div class="form-group">
                                  <input type="text" name="proName" class="form-control" placeholder="请输入商品分类">
                                </div>

                                <div class="form-group">
                                    <textarea name="proDesc" class="form-control" placeholder="请输入商品描述" rows="3"></textarea>
                                </div>
                                
                                <div class="form-group">
                                    <input type="text" name="num" class="form-control" placeholder="请输入商品库存">
                                </div>
                                <div class="form-group">
                                    <input type="text" name="size" class="form-control" placeholder="请输入商品尺码(例如36-45)">
                                </div>
                                <div class="form-group">
                                    <input type="text" name="oldPrice" class="form-control" placeholder="请输入原价">
                                </div>
                                <div class="form-group">
                                    <input type="text" name="price" class="form-control" placeholder="请输入现价">
                                </div>

                                <!-- 上传图片 -->
                                <div class="form-group file-group">
                                    <input type="hidden">
                                    <input type="file" id="fileupload" name="pic1" data-url="/product/addProductPic" multiple>
                                    <button type="button" class="btn btn-default">上传图片</button>
                                </div>

                                <div class="form-group">
                                    <img src="" alt="">
                                    <div class="imgbox"></div>
                                    <input type="hidden" name="productImg" class="form-control">
                                </div>
                        </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="submit btn btn-primary">确定</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <!-- 添加二级分类下拉框的模板 -->
    <script type="text/html" id="subcategory-dropdown">
        {{each rows}}
        <li><a data-id="{{$value.id}}" href="javascript:void();">{{$value.brandName}}</a></li>
        {{/each}}
    </script>

    <!-- 是否退出的模态框 -->
    <div id="logout-modal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">温馨提示</h4>
                </div>
                <div class="modal-body">
                    <p><span class="glyphicon glyphicon-info-sign"></span>您确定要退出后台管理系统吗？</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary">确定</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 执行echart方法，生成表格 -->
    <script src="./js/index.js"></script>
</body>
</html>